package com.zbkj.dal.entity.user;

import com.zbkj.dal.base.enums.BooleanEnums;
import lombok.Data;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author JinXinyu
 * @date 2024-03-10 12:19:50
 */
@Data
@TableName("eb_user_week_record")
public class UserWeekRecord implements Serializable {

    @TableId(value = "id", type = IdType.AUTO)
    @TableField("id")
    private Integer id;

    /**
     * 用户id
     */
    @TableField("user_id")
    private Integer userId;

    /**
     * 开始日期
     */
    @TableField("start_date")
    private Integer startDate;

    /**
     * 结束日期
     */
    @TableField("end_date")
    private Integer endDate;

    /**
     * 奖励金额
     */
    @TableField("reward")
    private BigDecimal reward;

    /**
     * 推广人数
     */
    @TableField("user_count")
    private Integer userCount;

    /**
     * 推广订单数
     */
    @TableField("order_count")
    private Integer orderCount;

    /**
     * 订单金额
     */
    @TableField("order_amount")
    private BigDecimal orderAmount;

    /**
     * 最后下单日期
     */
    @TableField("last_paid_time")
    private LocalDateTime lastPaidTime;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 创建人
     */
    @TableField("created_by")
    private Integer createdBy;

    /**
     * 更新时间
     */
    @TableField("update_time")
    private LocalDateTime updateTime;

    /**
     * 是否删除
     */
    @TableField("is_deleted")
    private Integer deleted;

    public static UserWeekRecord init(Integer userId, Integer startDate, Integer endDate) {
        UserWeekRecord userWeekRecord = new UserWeekRecord();
        userWeekRecord.setUserId(userId);
        userWeekRecord.setStartDate(startDate);
        userWeekRecord.setEndDate(endDate);
        userWeekRecord.setReward(BigDecimal.ZERO);
        userWeekRecord.setUserCount(0);
        userWeekRecord.setOrderCount(0);
        userWeekRecord.setOrderAmount(BigDecimal.ZERO);
        userWeekRecord.setCreateTime(LocalDateTime.now());
        userWeekRecord.setCreatedBy(userId);
        userWeekRecord.setUpdateTime(LocalDateTime.now());
        userWeekRecord.setDeleted(BooleanEnums.FALSE.getCode());
        return userWeekRecord;
    }
}
